from goods.models import SKU
from orders.models import OrderInfo, OrderGoods
from rest_framework import serializers
class OrderInfoSerializers(serializers.ModelSerializer):
    class Meta:
        model = OrderInfo
        fields=['order_id','create_time']

# ['count','price','sku']
class SKUSrializers(serializers.ModelSerializer):
    class Meta:
        model=SKU
        # fields = ['name','default_image']
        fields = "__all__"


class OrderGoodsSerializers(serializers.ModelSerializer):
    sku=SKUSrializers(read_only=True)
    class Meta:
        model=OrderGoods
        fields=['count','price','sku']


class OrderInfosSerializers(serializers.ModelSerializer):
    user = serializers.StringRelatedField()

    skus =OrderGoodsSerializers(many=True)
    class Meta:
        model = OrderInfo
        fields = '__all__'
